home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: gail.ripco.com!mambuhl
- From: mambuhl@ripco.com (Martin Ambuhl)
- Subject: Re: Strcat Doesn`t work
- X-Nntp-Posting-Host: foley.ripco.com
- Message-ID: <DL3u9F.9x5@rci.ripco.com>
- Sender: usenet@rci.ripco.com (Net News Admin)
- Organization: Ripco Internet BBS Chicago
- Date: Sat, 13 Jan 1996 05:36:51 GMT
- X-Ident-Sender: mambuhl
-
- ** Craig Cook ** <cookca@cs.purdue.edu> in
- <Pine.SOL.3.91.960111151925.25068C-100000@lore.cs.purdue.edu> asks:
-
- >Here is my excerpt of code in question:
- >Putword(int w, char *imageChar)
- >{
- > w = (w & 0xff);
- > strcat( imageChar, (const char *)w );
- >}
- >Why does it core dump? It should work right?
-
- No. Why should it work?
- (char *)w points to some location between 0 and 0xff. Do you have
- any reason to suppose a zero-terminated character array (a string)
- resides there? Hell, do you have any reason to suppose that it is even
- in your data region?
-
- It is also likely that imageChar is also not a string. You will
- probably find that
-
- #define Putword(x,y) ((y << CHAR_BIT) | (x & 0xff))
-
- or
-
- #define Putword(x,y) ((x << CHAR_BIT) | (y & 0xff))
-
- is closer to what you want.
-
- --
- * Martin Ambuhl net: mambuhl@ripco.com
- * Chicago, IL (USA)
-